package com.mini.rpc.provider;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@EnableConfigurationProperties
@SpringBootApplication
@Slf4j
public class RpcProviderApplication {

    public static void main(String[] args) {
        SpringApplication.run(RpcProviderApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            log.info("----------------- start beanDefinition ---------------------");
            // 打印出 IoC 容器中所有 BeanDefinition
            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.stream(beanNames).sorted().forEach(log::info);
            log.info("----------------- end beanDefinition ---------------------");
        };
    }

}